import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.Scanner;
public class Account{
    private String name;
    private static int id = 10000;
    private int secretcode;
    private double balance;
    private double rate;
    private int phonenumber;
    private double deposit;
    private double withdraw;
    Account(int secretcode, int balance, double rate, String name, int phonenumber, double deposit, double withdraw){
        this.secretcode = secretcode;
        this.balance = balance;
        this.rate = rate;
        this.name = name;
        this.phonenumber = phonenumber;
        this.deposit = deposit;
        this.withdraw = withdraw;
    }

        // 基础账户信息
    public void setPhone(int phonenumber1){
        phonenumber = phonenumber1;
        
    }
    public void setName(String input){
        name = input;//Cannot use this in a static contex
    }
    public void changeID(){
        id++;
    }

//模块一：登出系统
    // 检验账户
    public boolean testID(int _id){
        boolean test1;
        if(_id == id){
            test1 = true;
            return test1;
        }
        else{
            test1 = false;
            return test1;
        }
    }

        //检验密码（把这个作为“开口”的前提）
    public boolean testSecretcode(int load){
        boolean test2;
        if(load == secretcode){
            test2 = true;
            return test2;
            //System.out.println("Welcome! Dear" + name);
        }
        else{
            test2 = false;
            return test2;

        }
    }

//模块二：银行服务
        //密码登出与密码修改
    public void testNewcode(){
        System.out.println("请输入新密码.");
        Scanner num = new Scanner(System.in);
        int code = num.nextInt(); 
        this.setSecretcode(code);
        String s = String.valueOf(secretcode);//不能调用.length()方法检验数的长度，应该将其转化为字符串，调用String.ValudeOf(参数)方法
        if(s.length() == 6){
            System.out.println("设置成功!");
            this.lock();
        }
        else{
            System.out.println("密码长度必须为6");
        }
        }

    //设置变量 （工具方法）
    private void setSecretcode(int code){
        secretcode = code;
    }
    

    //存款业务
    public void setDeposit(double a){
        balance += a;
        System.out.println("存款金额： " + a);
        System.out.println("余额： " + balance);
        deposit = a;
    }

    //取款业务
    public void setWithdraw(double b){
        if(balance < b){
            System.out.println("检测到您的余额不足，无法完成提取业务");
        }
        else{
            balance -= b;
            System.out.println("存款金额： " + b);
            System.out.println("余额： " + balance);
            withdraw = b;
        }
    }
    
    //理财方案选择
    public void getRate(){
        System.out.println("当前活期利率：" + rate);
    }

//模块三：管理员管理
    //设定利率
    public double setRate(double c){
        rate = c;
        return rate;
    }
    //用户信息加密
    
    
    public void lock(){
        /*
        MessageDigest cc = MessageDigest.getInstance("MD5");
        String se = String.valueOf(secretcode);
        cc.update(se.getByte("UTF8"));
        byte s[] = se.digest();
        String result = "";
        for(int i = 0; i < s.length; i++){
        result += Integer.toHexString((0x000000ff & s[i]) | 0xffffff00).substring(6);
        System.out.println(ressult);
        */
        String se = String.valueOf(secretcode);
        se.hashCode();
        System.out.println("检测密码加密成果");
        System.out.println(se.hashCode());

    }
    
    
    //获取用户信息
        public int  getID(){
            return this.id;     
        }
        public String getName(){        
            return this.name;
        }
        public double getDeposit(){
            return this.deposit;
        }
        public double getWithdraw(){
            return this.withdraw;
        }
            //余额查询业务
        public double getBalance(){
            return this.balance;
        }
        public double gettheRate(){
            return this.rate;
        }
}
